package com.geek.bams.entity;

import com.geek.bams.exception.BalanceNotEnoughException;

import java.io.Serializable;

/**
 * @Desc TODO
 * @Author wangpeng
 * @Date 2025/10/10
 */
public abstract class Account implements Serializable {

    /** 成员属性 */
    //账户号码
    private Long id;
    //真实姓名
    private String name;
    //账户密码
    private String password;
    //身份证号码
    private String personId;
    //客户的电子邮箱
    private String email;
    //账户余额
    private double balance;

    //构造方法
    public Account() {
    }

    public Account(Long id, String name, String password, String personId, String email, double balance) {
        this.id = id;
        this.name = name;
        this.password = password;
        this.personId = personId;
        this.email = email;
        this.balance = balance;
    }


    //Getter和Setter方法
    /**
     * 获取
     * @return id
     */
    public Long getId() {
        return id;
    }

    /**
     * 设置
     * @param id
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * 获取
     * @return name
     */
    public String getName() {
        return name;
    }

    /**
     * 设置
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * 获取
     * @return password
     */
    public String getPassword() {
        return password;
    }

    /**
     * 设置
     * @param password
     */
    public void setPassword(String password) {
        this.password = password;
    }

    /**
     * 获取
     * @return personId
     */
    public String getPersonId() {
        return personId;
    }

    /**
     * 设置
     * @param personId
     */
    public void setPersonId(String personId) {
        this.personId = personId;
    }

    /**
     * 获取
     * @return email
     */
    public String getEmail() {
        return email;
    }

    /**
     * 设置
     * @param email
     */
    public void setEmail(String email) {
        this.email = email;
    }

    /**
     * 获取
     * @return balance
     */
    public double getBalance() {
        return balance;
    }

    /**
     * 设置
     * @param balance
     */
    public void setBalance(double balance) {
        this.balance = balance;
    }

    public String toString() {
        return "Account{id = " + id + ", name = " + name + ", password = " + password + ", personId = " + personId + ", email = " + email + ", balance = " + balance + "}";
    }

    //成员方法
    /**
     * 存款方法
     * @param money  存钱
     * @return  账户本身
     */
    public final Account deposit(double money){
        this.balance+=money;
        return this;
    }

    /**
     * 取款方法
     * @param money  取钱
     * @return  账户本身
     */
    public abstract Account withdraw(double money) throws BalanceNotEnoughException;
}
